package com.lzh.financial.util;

import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.io.IOUtils;
import org.apache.ibatis.io.Resources;

import java.io.IOException;
import java.io.InputStream;

@Slf4j
public class ReadJson {

    public static JSONObject getJSONObjectFromFile(String fileName) {

        String nation = null;
        try {
            InputStream resourceAsStream = Resources.getResourceAsStream("config/" + fileName);
            nation = IOUtils.toString(resourceAsStream,"UTF-8");
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONObject jsonObject= (JSONObject) JSONObject.parse(nation);
        if (nation!=null) {
            return RebornJson.success("获取成功",jsonObject);
        }
       return null;
    }
}